﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FileDescription.cs" company="">
//   
// </copyright>
// <summary>
//   The file description.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Core
{
    /// <summary>
    ///   The file description.
    /// </summary>
    public class FileDescription
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FileDescription"/> class.
        /// </summary>
        /// <param name="nameWithoutExtension">
        /// The name without extension. 
        /// </param>
        /// <param name="extension">
        /// The extension. 
        /// </param>
        /// <param name="size">
        /// The size. 
        /// </param>
        public FileDescription(string nameWithoutExtension, string extension, long size)
        {
            this.NameWithoutExtension = nameWithoutExtension;
            this.Extension = extension;
            this.Size = size;
            this.MimeType = MimeTypes.GetByExtension(this.Extension, NotExistsAction.ReturnNull)
                            ??
                            new MimeType
                                {
                                    ContentType = this.Extension, 
                                    FileExtensions = new[] { this.Extension }, 
                                    Name = this.Extension
                                };
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///   Gets the extension.
        /// </summary>
        public string Extension { get; private set; }

        /// <summary>
        ///   Gets the mime type.
        /// </summary>
        public MimeType MimeType { get; private set; }

        /// <summary>
        ///   Gets the name.
        /// </summary>
        public string Name
        {
            get
            {
                return this.NameWithoutExtension + "." + this.Extension;
            }
        }

        /// <summary>
        ///   Gets the name without extension.
        /// </summary>
        public string NameWithoutExtension { get; private set; }

        /// <summary>
        ///   Gets the size.
        /// </summary>
        public long Size { get; private set; }

        #endregion
    }
}